<template>
    <a-drawer
        :destroyOnClose="true"
        title="任务详情"
        :placement="placement"
        :closable="closable"
        :visible="visible"
        :maskClosable="maskClosable"
        :width="width"
        @close="cancel">

        <LTable
            ref="taskList"
            size="middle"
            rowKey="id"
            :formAttributes="formAttributes"
            :columns="columns"
            :initQuery="initQuery"
            :initOrder="initOrder"
            axiosUrl="/flowInstance/instanceTask"
            :showPagination="false"
            :showQueryForm="true">

            <span slot="action" slot-scope="text, record">
                <a @click="handleTask(record)">查看任务</a><a-divider type="vertical" />
            </span>

        </LTable>
    </a-drawer>
</template>

<script>
import LTable from '@/components/lt/LTable' 
import request from '@/utils/flowRequest'
import {SysMixin} from '@/mixins/SysMixin'
import notification from 'ant-design-vue/es/notification'

export default {
    name:'drawerTask',
    components:{
       LTable
    },
    mixins:[SysMixin],
    props:{
        title:String,
        placement:{
            type:String,
            default:'right'
        },
        closable:{
            type:Boolean,
            default:true
        },
        maskClosable:{
            type:Boolean,
            default:true
        }
    },
    data() {
        return {
            request,
            visible: false,
            confirmLoading: false,
            width:document.documentElement.clientWidth-208,
            url: {
                task: '/flowInstance/instanceTask'
            },
            initQuery:[ {field: 'procInstId', val: '-1'} ],
            initOrder: [{field: 'startTime', val: 'asc'}],
            formAttributes: [],
            columns:[
                {
                    title: '#',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                {
                    title: '环节名称',
                    dataIndex: 'name'
                },
                {
                    title: '处理人编号',
                    dataIndex: 'assignee'
                    
                },
                {
                    title: '处理人姓名',
                    dataIndex: 'empName'
                    
                },
                {
                    title: '任务开始时间',
                    dataIndex: 'startTime'
                },
                {
                    title: '任务结束时间',
                    dataIndex: 'endTime'
                },
                {
                    title: '审批时间',
                    dataIndex: 'processingTime'
                },
                {
                    title: '审批意见',
                    dataIndex: 'opinion',
         
         
                }
            ]
        }
    },
    methods: {
        open(instanceId) {
            this.visible = true;
            if (instanceId) {
                this.initQuery = [ {field: 'procInstId', val: instanceId} ]
                this.$nextTick(() => {
                    this.$refs["taskList"].searchQuery()
                })
                
            }
        },
        queryInstanceTask(instanceId) {
            request.get(this.url.task,{params:{instanceId: instanceId}}).then(res => {
                if(res.success){
                    this.$message.success(res.message);
                } else {
                    notification.error({ message: '系统提示', description: res.message || "执行出现错误"})
                }
            })
        },
        cancel(){
            this.visible = false
            this.$emit('handleCancel');
        }
    }
}
</script>

<style  scoped>


</style>